package com.icloud.article.boot.controller.admin;

import com.icloud.article.boot.dto.ArticleSensitiveAddDto;
import com.icloud.article.boot.dto.ArticleSensitivePageDto;
import com.icloud.article.boot.dto.ArticleSensitiveUpdateDto;
import com.icloud.article.boot.service.ArticleSensitiveService;
import com.icloud.article.boot.vo.ArticleSensitiveVo;
import com.icloud.common.core.api.CommonResult;
import com.icloud.common.web.vo.PageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "后台敏感词库接口")
@RequestMapping("/admin/sensitive")
@RequiredArgsConstructor
public class AdminArticleSensitiveController {
    private final ArticleSensitiveService articleSensitiveService;

    @ApiOperation("查询")
    @PostMapping("/page")
    @ResponseBody
    public CommonResult<PageVO<ArticleSensitiveVo>> page(@Validated @RequestBody ArticleSensitivePageDto dto){
        return CommonResult.success(articleSensitiveService.sensitivePage(dto));
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    @ResponseBody
    public CommonResult<Boolean> add(@Validated @RequestBody ArticleSensitiveAddDto dto){
        return CommonResult.success(articleSensitiveService.add(dto));
    }

    @ApiOperation("修改")
    @PostMapping("/update")
    @ResponseBody
    public CommonResult<Boolean> update(@Validated @RequestBody ArticleSensitiveUpdateDto dto){
        return CommonResult.success(articleSensitiveService.update(dto));
    }
}
